<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="cn.edu.scau.cmi.carol.javabean.*" %>
<%@ page import="cn.edu.scau.cmi.carol.sex.Sex" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>checkYourInformation</title>
</head>
<body>

<% 
try{
	User user_login=(User)session.getAttribute("user_login");
	Connection conn=Conn.connect();
	String selectsql="select * from student where studentID=?";
    PreparedStatement ps=conn.prepareStatement(selectsql);    
    ps.setInt(1,user_login.getStudentID());
    ResultSet rs=ps.executeQuery();
    
    List<User> list_login=new ArrayList<>();        
    while(rs.next()){    	
    user_login.setName(rs.getString(2));
	user_login.setSex(Sex.sexToString(rs.getInt(3)));
	user_login.setAge(rs.getInt(4));
	list_login.add(user_login);
    }
    request.setAttribute("list_login", list_login);
    rs.close();
    ps.close();
    conn.close();
%>
<table>
<tr>
<th>studentID</th>
<th>name</th>
<th>sex</th>
<th>age</th>
</tr>
<% 
	for (User user: list_login) {
%>
<tr>
<td><%=user_login.getStudentID() %></td>
<td><%=user_login.getName()%></td>
<td><%=user_login.getSex() %></td>
<td><%=user_login.getAge() %></td>
</tr>
</table>
<%  
}
}
catch(Exception e){
	e.printStackTrace();
}
%>

<a href="studentUpdate.jsp">updateYourInformation</a>
</body>
</html>